<%-- 
    Document   : new_visit_other
    Created on : Nov 18, 2013, 2:44:30 PM
    Author     : Mansur
--%>

<%@ include file="/WEB-INF/jsp/include/page_header.jspf" %>
<%@ taglib prefix="display" uri="http://displaytag.sf.net"%>
<%@page contentType="text/html" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>.: Ship Visit :.</title>    
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.blockUI.js"></script>   
        <script type="text/javascript">
            $(function() {
                $("#datepicker2").datepicker({
                    showOn: "button",
                    buttonImage: "${pageContext.request.contextPath}/images/icon/calendar.gif",
                    buttonImageOnly: true,
                    changeMonth: true,
                    dateFormat: 'dd/mm/yy',
                    changeYear: false,
                    maxDate: new Date(),
                    minDate: minDate()
                });
            });
            
            function validateEmpty(){
                var validate = true;
                if($('#vesselId').val() === '' || $('#datepicker2').val() === '' || $('#location').val() === '' || $('#desc').val() === ''){
                    alert('All form fields are required!');
                    validate  = false;
                }
                return validate;
            }
            
            function unblockUI() {
                $.unblockUI();
            }
            
            function blockUI () {
                $.blockUI();
            }
            
            function minDate(){
                var year = ${actionBean.currentYear};
                var date = new Date(year,0,1);
                return date;
            }
            
            function popupWin(id) {
                var url = '${pageContext.request.contextPath}/shipVisitFlow?editDocument&idStaff=' + id;
                var left = (screen.width/2)-(1000/2);
                var top = (screen.height/2)-(1000/2);                
                var params = 'width=1000';
                params += ', height=1000';
                params += ', top=' + top;
                params += ', left=' + left;
                //params += ', fullscreen=yes';
                params += ', directories=no';
                params += ', location=no';
                params += ', menubar=no';
                params += ', resizable=no';
                params += ', scrollbars=yes';
                params += ', status=no';
                params += ', toolbar=no';                
                newwin = window.open(url, 'PopUp', params);
                if (window.focus) {
                    newwin.focus();
                }                
                return false;
            }
        </script>
        <style>
            .validateTips { border: 1px solid transparent; padding: 0.3em; color: red; font-weight: bold}
        </style>
    </head>
    <body>
        <s:useActionBean beanclass="exatrez.stripes.util.ListUtil" var="list"/>
        <s:form beanclass="exatrez.stripes.action.ShipVisitFlowAction" name="form1">   
            <s:hidden name="counterId" />
            <s:hidden name="currentYear" />
            <div>
                <fieldset>
                    <div id="page-title">
                        <span class="title">Ship Visit</span>
                    </div>
                    <div style="align: center">
                        <span class="sub-title">Ship visit target as per year ${actionBean.currentYear}</span>
                        <display:table class="tablecloth" name="${actionBean.listCounter}" requestURI="/shipVisit" id="line" style="width:50%">
                            <display:column title="Target Visit" property="target"/>
                            <display:column title="No. of visit" property="visited"/>
                            <display:column title="Total Balance"><c:out value="${line.target - line.visited}" /></display:column>                 
                        </display:table>
                    </div>
                    <div id="page-title">
                        <span class="title">New Ship Visit Form</span>
                    </div>
                    <s:messages/>
                    <s:errors/>
                    <p class="validateTips"><em>All form fields are required except Attachment.</em></p>
                    <p>
                        <label>Vessel Name :</label>
                        <s:select name="shipVisitFlow.vessel.vesselId" id="vesselId" style="width:200px">
                            <s:option value="">Please Choose</s:option>
                            <s:options-collection collection="${list.vesselList}" label="vesselName" value="vesselId"/>
                        </s:select>
                    </p>
                    <p>
                        <label>Date Visit :</label>
                        <s:text name="shipVisitFlow.dateVisit" id="datepicker2" formatType="date" formatPattern="dd/MM/yyyy" readonly="true"/>     
                    </p>
                    <p>
                        <label>Location :</label>
                        <s:text name="shipVisitFlow.location" id="location" size="55" class="uppercase" />
                    </p>
                    <p>
                        <label style="vertical-align: top">Description :</label>
                        <s:textarea name="shipVisitFlow.description" id="desc" rows="10" cols="50"/>
                    </p>
                    <p>
                        <label>Attachment/s :</label>
                        <s:button name="" value="Upload..." class="btn" onclick="return popupWin('${actionBean.staffId}');"/>
                    </p>
                    </p>
                    <p>
                        <label>&nbsp;</label>
                        <s:submit name="submit" value="Submit" class="btn" onclick="return validateEmpty();"/>
                    </p>
                </fieldset>
            </div>
        </s:form>
    </body>
</html>